package org.example.entitys.systems;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.entitys.managers.Student;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @Description 用户基类的实体类
 * @Author 魏锴
 * @Date 2023/11/10
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
    private int id = -1;//用户id
    private String name;//姓名
    private String password;//密码
    private String gender;//性别
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birthday;//生日
    private String phone;//电话
    private String email;//邮箱
    private int status = 1;//账号状态 1表示正常,2表示异常

    public User(Student student) {//通过student获得user
        this.name = student.getStu_name();
        this.password = this.getName() + "123456789";
        this.gender = "M";
        this.birthday = new Date();
        this.phone = "";
        this.email = "";
        this.status = 1;
    }

    public User(Teacher teacher) {//通过student获得user
        this.name = teacher.getTeacher_name();
        this.password = this.getName() + "123456789";
        this.gender = "M";
        this.birthday = new Date();
        this.phone = "";
        this.email = "";
        this.status = 1;
    }
}
